package 结对作业2;
import java.util.*;

public class Calculation {
    public static void main(String[] args) {
        System.out.println("请输入要生成的题目数：");
        Scanner number = new Scanner(System.in);
        int n = number.nextInt();
        for (int i = 1; i <= n; i++) {
            System.out.println("题目" + i + ":");
            Scanner reader = new Scanner(System.in);
            Rational result = new Rational();
            String str = reader.nextLine();
            ChangeExpress change = new ChangeExpress();
            change.setOriginalExpression(str);
            change.changedWay();//后缀式化
            MyDcRational calculate = new MyDcRational();//后缀式计算
            result = calculate.evaluate(change.changedExpression);
            int a = result.getNumerator();
            int b = result.getDenominator();
            if (b == 1) {
                System.out.println("result=" + a);
            } else {
                System.out.println("result=" + a + "/" + b);
            }

        }

    }
}